home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Kant Generator Pro 1.2 / src / Shell ƒ / cancel.c < prev    next >
C/C++ Source or Header  |  1994-09-23  |  1KB  |  40 lines

  1. #include "cancel.h"
  2. #include "main.h"
  3.  
  4. #define TheCancelKey    '.'
  5.  
  6. Boolean DealWithOtherPeople(void)
  7. {
  8.     /* this is just a small useful function to see if the user has cancelled */
  9.     /* a lengthy operation with command-period; could come in handy, I suppose, */
  10.     /* in a somewhat bizarre set of circumstances... */
  11.     /* Note that this procedure will break under AUX */
  12.     /* Note also that this returns TRUE if there has been no attempt to cancel */
  13.     
  14.     Boolean            foundEvent;
  15.     EvQElPtr        eventQPtr;
  16.     QHdrPtr            eventQHdr;
  17.     char            thisChar;
  18.     long            isCmdKey;
  19.     
  20.     foundEvent=FALSE;
  21.     eventQHdr=GetEvQHdr();
  22.     eventQPtr=(EvQElPtr)(eventQHdr->qHead);
  23.     while ((eventQPtr!=0L) && (!foundEvent))
  24.     {
  25.         if (eventQPtr->evtQWhat==keyDown)
  26.         {
  27.             thisChar=(char)((eventQPtr->evtQMessage)&charCodeMask);
  28.             isCmdKey=(eventQPtr->evtQModifiers)&cmdKey;
  29.             if (isCmdKey!=0L)
  30.                 foundEvent=(thisChar==TheCancelKey);
  31.         }
  32.         if (!foundEvent)
  33.             eventQPtr=(EvQElPtr)(eventQPtr->qLink);
  34.     }
  35.  
  36.     while (HandleSingleEvent(FALSE)) {};
  37.     
  38.     return !foundEvent;
  39. }
  40.